<?php
namespace App;

use Phalcon\Exception;
use App\Config\Bootstrap;
use App\Library\App;

date_default_timezone_set('Etc/GMT-8');
define("DS", DIRECTORY_SEPARATOR);
define("BASE_PATH", realpath(dirname(__FILE__) . "/../"));
define("APP_PATH", BASE_PATH . '/App/');

if(strpos(strtolower($_SERVER['HTTP_HOST']), 'joypaw.com') !== false) {
    define('ENVIRONMENT', 'production');
} else {
    define('ENVIRONMENT', 'development');
}

if(defined('ENVIRONMENT')) {
    switch(ENVIRONMENT) {
        case 'development':
            error_reporting(E_ALL);
            ini_set("display_errors", "On");
            break;
        case 'testing':
        case 'production':
        default:
            error_reporting(0);
            ini_set("display_errors", "Off");
            break;
    }
}

try {
    include APP_PATH . 'Config/Bootstrap.php';
    $bootstrap = new Bootstrap();
    $bootstrap->start();
} catch(\PDOException $ex) {
    App::showError($ex);
} catch(Exception $ex) {
    App::showError($ex);
} catch(\Exception $ex) {
    App::showError($ex);
}
